package com.yifengm.controller;

import com.yifengm.common.R;
import com.yifengm.pojo.Admin;
import com.yifengm.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @RequestMapping("/login")
    public R Login(String name,String password){
        System.out.println(name+password);
        Admin admin = loginService.Login(name, password);
        if (admin.getName() != null && !"".equals(admin.getName())){
            return R.ok().data("admin",admin);
        }else {
            return R.error().data("error","用户名或密码错误");
        }

    }
}
